package cn.it.hbtt.Servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.it.hbtt.daoimg.Buycarimg;
import cn.it.hbtt.daoimg.Dropimg;
import cn.it.hbtt.daoimg.Orderimg;
import cn.it.hbtt.daoimg.Orderimg1;
import cn.it.hbtt.entity.User;

/**
 * Servlet implementation class test
 */
@WebServlet("/test")
public class test extends HttpServlet {
	private static final long serialVersionUID = 1L;
 
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String showid=request.getParameter("a");
		PrintWriter out = response.getWriter();
		User user = (User) request.getSession().getAttribute("q");
		String name = user.getLoginName();
		Buycarimg buy=new Buycarimg();
		Orderimg ord=new Orderimg();
		Orderimg1 ord1=new Orderimg1();
		Dropimg drop = new Dropimg();
		drop.dropimg(showid);
			HttpSession s = request.getSession();
			s.setAttribute("q2", ord1.ord(name));
			s.setAttribute("aa", buy.buycar(name));
			s.setAttribute("q3",buy.cost );
			String str = "<script  type='text/javascript'>";
		//	str += "alert('该账户没有注册！');";
			str += "location.href='http://localhost:8080/easybuy/Index.jsp'";
			str += "</script>";
			out.write(str);
			out.flush();

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
